# -*- Python -*-
import talk

Import('env')

# For peerconnection, we need additional flags only for GCC 4.6+.
peerconnection_lin_ccflags = []

if env.Bit('linux'):
  # Detect the GCC version and update peerconnection flags.
  (major, minor, rev) = env.GetGccVersion()
  if major > 4 or (major == 4 and minor >= 6):
    peerconnection_lin_ccflags = ['-Wno-error=unused-but-set-variable']


if env.Bit('have_webrtc_voice') and env.Bit('have_webrtc_video'):
  # local sources
  talk.Library(
    env,
    name = 'peerconnection',
    srcs = [
      'audiotrack.cc',
      'jsepicecandidate.cc',
      'jsepsessiondescription.cc',
      'mediaconstraintsinterface.cc',
      'mediastream.cc',
      'mediastreamhandler.cc',
      'mediastreamproxy.cc',
      'mediastreamsignaling.cc',
      'mediastreamtrackproxy.cc',
      'peerconnectionfactory.cc',
      'peerconnection.cc',
      'portallocatorfactory.cc',
      'roapmessages.cc',
      'roapsession.cc',
      'roapsignaling.cc',
      'videorendererimpl.cc',
      'videotrack.cc',
      'webrtcsdp.cc',
      'webrtcsession.cc',
    ],
    lin_ccflags = peerconnection_lin_ccflags
  )

  talk.Unittest(
    env,
    name = 'peerconnection',
    srcs = [
      'test/fakeaudiocapturemodule.cc',
      'test/fakeaudiocapturemodule_unittest.cc',
      'test/fakevideocapturemodule.cc',
      'test/fileframesource.cc',
      'test/i420framesource.cc',
      'test/staticframesource.cc',
      'jsepsessiondescription_unittest.cc',
      'mediastream_unittest.cc',
      'mediastreamhandler_unittest.cc',
      'mediastreamsignaling_unittest.cc',
      'peerconnectioninterface_unittest.cc',
      'peerconnection_unittest.cc',
      'peerconnectionfactory_unittest.cc',
      'roapmessages_unittest.cc',
      'roapsession_unittest.cc',
      'roapsignaling_unittest.cc',
      'webrtcsdp_unittest.cc',
      'webrtcsession_unittest.cc',
    ],
    libs = [
      'base',
      'expat',
      'json',
      'p2p',
      'phone',
      'srtp',
      'xmllite',
      'xmpp',
      'yuvscaler',
      'peerconnection',
    ],
    win_link_flags = [('', '/nodefaultlib:libcmt')[env.Bit('debug')]],
    lin_libs = [
      'sound',
    ],
    mac_libs = [
      'crypto',
      'ssl',
    ],
   )
